package com.example.chinawenddingexpo.repository;

import com.example.chinawenddingexpo.model.Exhibitor;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ExhibitorRepository extends JpaRepository<Exhibitor, Long> {
    
    List<Exhibitor> findByActiveTrueOrderByPriorityDesc();
    
    List<Exhibitor> findByTypeAndActiveTrueOrderByPriorityDesc(Exhibitor.ExhibitorType type);
    
    List<Exhibitor> findByCompanyNameContainingIgnoreCaseAndActiveTrue(String companyName);
    
    @Query("SELECT e FROM Exhibitor e WHERE e.type = :type AND e.active = true AND e.discountRate > 0 ORDER BY e.discountRate DESC")
    List<Exhibitor> findDiscountExhibitorsByType(@Param("type") Exhibitor.ExhibitorType type);
}